home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / comm2 / xbtx.lha / Source / BTXService.hpp < prev    next >
C/C++ Source or Header  |  1995-12-03  |  7KB  |  220 lines

  1. /*
  2. **    $Id: BTXService.hpp 1.4 1995/12/03 12:16:23 olsen Exp olsen $
  3. **
  4. **    :ts=4
  5. */
  6.  
  7. /*
  8.  * Copyright © 1995 by Olaf Barthel, All Rights Reserved
  9.  *
  10.  * Redistribution and use in source and binary forms, with or without
  11.  * modification, are permitted provided that the following conditions
  12.  * are met:
  13.  * 1. Redistributions of source code must retain the above copyright
  14.  *    notice, this list of conditions and the following disclaimer.
  15.  * 2. Redistributions in binary form must reproduce the above copyright
  16.  *    notice, this list of conditions and the following disclaimer in the
  17.  *    documentation and/or other materials provided with the distribution.
  18.  *
  19.  * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
  20.  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  21.  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
  22.  * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  23.  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  24.  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  25.  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  26.  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  27.  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  28.  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29.  *
  30.  * This software has not been validated by the ``Bundesamt fuer Zulassungen in
  31.  * der Telekommunikation'' of the ``Deutsche Bundepost Telekom'' and thus
  32.  * must not be used for accessing the BTX-Network of the Telekom in Germany.
  33.  *
  34.  * Diese Software hat keine Zulassung durch das Bundesamt fuer Zulassungen in
  35.  * der Telekommunikation der Deutschen Bundespost Telekom und darf daher nicht
  36.  * am Netz der Deutschen Bundespost Telekom in Deutschland betrieben werden.
  37.  */
  38.  
  39. #ifndef _BTXSERVICE_HPP
  40. #define _BTXSERVICE_HPP 1
  41.  
  42. /******************************************************************************/
  43.  
  44. #include <stdio.h>
  45. #include <stdarg.h>
  46.  
  47. /******************************************************************************/
  48.  
  49. class BTXService;
  50.  
  51. #ifndef _TYPES_HPP
  52. #include "Types.hpp"
  53. #endif
  54.  
  55. #ifndef _IOCHANNEL_HPP
  56. #include "IOChannel.hpp"
  57. #endif
  58.  
  59. #ifndef _BTXDISPLAY_HPP
  60. #include "BTXDisplay.hpp"
  61. #endif
  62.  
  63. #ifndef _APPLICATION_HPP
  64. #include "Application.hpp"
  65. #endif
  66.  
  67. #ifndef _FONT_H
  68. #include "Font.h"
  69. #endif
  70.  
  71. /******************************************************************************/
  72.  
  73. enum
  74. {
  75.     MODE_Unknown,
  76.     MODE_3in4,
  77.     MODE_8Bit
  78. };
  79.  
  80. /* information stored at every character location */
  81. struct screen_cell
  82. {
  83.     unsigned short    chr;
  84.     unsigned short    attr;       /* assigned attributes */
  85.     unsigned short    mark;       /* markers for each attribute */
  86.     unsigned short    real;       /* really displayed attributes (size !) */
  87.     unsigned char    set;
  88.     unsigned char    fg;
  89.     unsigned char    bg;
  90. };
  91.  
  92. struct terminal_status
  93. {
  94.     int cursorx, cursory;            /* cursor position (1 based)  */
  95.     int cursor_on;
  96.     int serialmode;                 /* 1=serial, 0=parallel       */
  97.     int wrap;                        /* wraparound ?               */
  98.     int par_attr;                    /* store all attributes       */
  99.     int par_fg, par_bg;
  100.     int G0123L[5];                    /* which set is addressed by G0, ... */
  101.     int leftright[2];                /* actual lower/upper character set  */
  102.     int lastchar;
  103.     int sshift;
  104.     int save_left;                    /* unload L set and invoke previous set  */
  105.     int prim, supp;                 /* where is the prim set (service break) */
  106.     int service_break;                /* (is the protect attr active ?)         */
  107.     int drcs_bits, drcs_step;
  108.     int drcs_w, drcs_h;
  109.     int col_modmap;                 /* modify 1:colormap, 0:DCLUT */
  110.     int clut;                        /* 0 based ! */
  111.     int scroll_upper, scroll_lower;
  112.     int scroll_impl, scroll_area;
  113.     int hold_mosaic;
  114. };
  115.  
  116. class BTXService
  117. {
  118.     public:
  119.  
  120.         BTXService();
  121.         ~BTXService();
  122.  
  123.         LONG Open(BTXDisplay *Disp,Application *Appl);
  124.         VOID Close(VOID);
  125.  
  126.         int ProcessInput(VOID);
  127.  
  128.         UBYTE ConvertChar(int Char,int Set,int Diacritical_Mark);
  129.         VOID GetMatrix(UBYTE *Matrix,int *CursorX,int *CursorY);
  130.  
  131.         VOID ToggleReveal(VOID);
  132.  
  133.         int rows, fontheight;                /* 20 rows(12 high) or 24 rows(10 high) */
  134.  
  135.     private:
  136.  
  137.         BTXDisplay     *AppDisplay;
  138.         Application    *App;
  139.  
  140.         struct screen_cell screen[24][40];    /* information for every character */
  141.         int reachedEOF;
  142.         struct terminal_status t,backup;    /* local terminal status */
  143.         unsigned int pushback;                // can push up to four bytes back into the input stream
  144.         UBYTE pushedback[4];                // bytes pushed back if any
  145.         UBYTE data[4][2*FONT_HEIGHT];        /* local font definition */
  146.         FILE *protocolfile;
  147.  
  148.         FILE *telefile;                        // Telesoftware landet hier
  149.         char telename[256];                    // Name sollte lang genug sein
  150.         long telesize;                        // Länge der Datei
  151.         char teledate[20];                    // Datum, sofern vorhanden
  152.         int telemode;                        // Kodierung, entweder 3-in-4 oder 8-Bit
  153.         int telesequence;                    // Sequenznummer
  154.         BOOL teledownload;                    // True, falls Download erlaubt ist
  155.         unsigned char telebuffer[3000];        // Blockpuffer
  156.  
  157.         int transparent_max;                // Wieviele Bytes noch, bis der transparente Modus
  158.                                             // verlassen wird?
  159.         int transparent_collected;            // Wieviele Bytes schon im Puffer stecken
  160.  
  161.         unsigned char transparent_buffer[256];    // Blockpuffer
  162.  
  163.         BOOL reveal;
  164.  
  165.         int transferTimeStamp;                // Der ganze andere Kram für FIF
  166.         UWORD transferID;
  167.         BOOL is_fif;
  168.         int blockNumber,numberOfBlocks;
  169.         char restartCode[40],continueCode[40];
  170.         int restartLen,continueLen;
  171.         UWORD blockChecksum;
  172.         char fileName[256];
  173.         char dateTime[16];
  174.         ULONG fileLength;
  175.         int fileCoding;
  176.         char codingString[256];
  177.         char userField[256];
  178.         char destinationName[256];
  179.         int compressionMode;
  180.         ULONG fileChecksum;
  181.  
  182.         void init_layer6(void);
  183.         int process_BTX_data(void);
  184.         inline int layer2getc(void);
  185.         inline void layer2ungetc(int c);
  186.         void default_sets(void);
  187.         void move_cursor(int cmd, int y=0, int x=0);
  188.         int primary_control_C0(int c1);
  189.         void supplementary_control_C1(int c1, int fullrow);
  190.         void do_US(void);
  191.         void do_ESC(void);
  192.         int do_CSI(void);
  193.         void do_DRCS(void);
  194.         void do_DRCS_data(int c);
  195.         void log_DRC(int c, int bits);
  196.         void do_DEFCOLOR(void);
  197.         void do_DEFFORMAT(void);
  198.         void do_RESET(void);
  199.         void do_Telesoftware(void);
  200.         void set_attr(int a, int set, int col, int mode);
  201.         void output(int c);
  202.         void redrawc(int x, int y);
  203.         void updatec(int real, int x, int y);
  204.         void redraw_screen_rect(int x1, int y1, int x2, int y2);
  205.         void update_DRCS_display(int start, int stop, int step);
  206.         void clearscreen(void);
  207.         void scroll(int up);
  208.         void write(const STRPTR what,int len);
  209.         int decode_3in4(const UBYTE *data,UBYTE *out,int total);
  210.         void do_TransparentData(void);
  211.         void do_FIF(void);
  212.  
  213.         /**********************************************************************/
  214.  
  215.         int LZH_Decode(FILE *fi, FILE *fo, long filesize, ULONG *CRC_32);
  216.         int RLE_Decode(FILE *fi,FILE *fo,long filesize,ULONG *CRC_32);
  217. };
  218.  
  219. #endif    // _BTXSERVICE_HPP
  220.